<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>商品详情</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <a class="btn" href="{:U('add')}">新增 商品</a>
            <a class="btn" href="{:U('addsize' , array('goods_id' => $goods[0]['goods_id']))}">新增 尺码</a>
            <button class="btn ajax-post" url="{:U('changeStatus?method=resumeUser')}" target-form="ids">启 用</button>
            <button class="btn ajax-post" url="{:U('changeStatus?method=forbidUser')}" target-form="ids">禁 用</button>
            <button class="btn ajax-post confirm" url="{:U('changeStatus?method=deleteUser')}" target-form="ids">删 除</button>

        </div>

        <!-- 高级搜索 -->
		<!-- <div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="请输入用户昵称或者ID">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
			</div>
		</div> -->
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
			<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
			<th class="">ID</th>
			<th class="">所属分类</th>
			<th class="">图片</th>
			<th class="">商品名</th>
			<th class="">价格</th>
			<th class="">型号</th>
			<th class="">状态</th>
			<th class="">添加时间</th>
			<th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="goods">
		<foreach name="goods" item="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
			<td>{$vo.goods_id} </td>
			<td>{$vo.classify_id}</td>
			<td><img src="./Uploads/{$vo.path}" width="50px;" alt=""></td>
			<td>{$vo.name}</td>
			<td>{$vo.price}</td>
			<td>{$vo.number}</td>
			<td>{$vo.status}</td>
			<td>{$vo.addtime}</td>
			<td><eq name="vo.status" value="1">
				<a href="{:U('User/changeStatus?method=forbidUser&id='.$vo['uid'])}" class="ajax-get">禁用</a>
				<else/>
				<a href="{:U('price' , array('goods_id' => $vo['goods_id'] , 'price' => $vo[price]))}" >修改价格</a>
				</eq>
                </td>
		</tr>
		</foreach>
		<tr>
			<td></td>
		</tr>
		<!-- 商品尺码 -->
		<thead>
			<tr>
				<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
				<th class="">ID</th>
				<th class="">父级ID</th>
				<th class="">商品尺码</th>
				<th class="">销量</th>
				<th class="">尺码对应库存</th>
				<th class="">添加时间</th>
				<th class="">操作</th>
			</tr>
		</thead>
		<foreach name="size" item="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
			<td>{$vo.attr_id} </td>
			<td>{$vo.goods_id}</td>
			<td>{$vo.size.0.size}</td>
			<td>{$vo.sale}</td>
			<td>{$vo.store}</td>
			<td>{$vo.addtime}</td>
			
			<td><eq name="vo.status" value="1">
				<a href="{:U('User/changeStatus?method=forbidUser&id='.$vo['uid'])}" class="ajax-get">禁用</a>
				<else/>
				<a href="{:U('modify' , array('attr_id' => $vo['attr_id'] , 'size' => $vo[size][0][size]))}" >修改</a>
				
				</eq>
                <a href="#" class='del ajax-get' attr_id = '{$vo.attr_id}' >删除</a>
            </td>
		</tr>
		</foreach>
		<tr>
			<td></td>
		</tr>
		<thead>
			<tr>
				<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
				<th class="">ID</th>
				<th class="">父级ID</th>
				<th class="">点击量</th>
				<th class="">访问量</th>
				<th class="">添加时间</th>
			</tr>
		</thead>
		<foreach name="report" item="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
			<td>{$vo.report_id} </td>
			<td>{$vo.goods_id}</td>
			<td>{$vo.views}</td>
			<td>{$vo.access}</td>
			<td>{$vo.addtime}</td>
			
		</tr>
		</foreach>

		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
    <div class="form-item">
        <button class="btn btn-return" id="fan">返 回</button>
        <script>
        	$('#fan').click(function(){
        		window.location.href = "{:U('showlist')}";
        	});

        </script>
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('{:U('Goods/showlist')}');

    // 删除尺码表
    $('.del').click(function(){
    	if(confirm("确定要删除数据吗？")) {
    		attr_id = $(this).attr('attr_id');

	    	$.get('{:U("Goods/del")}' , {attr_id : attr_id} , function(data)
	    	{	
	    		if (data) {
	    			$('.del').each(function(){
	    				if ($(this).attr('attr_id') == attr_id) {
	    					$(this).parent().parent().remove();
	    				};	
	    			});
	    		};

	    	});
    	}; 
    });



	</script>
</block>
